import { View } from '@tarojs/components';
import { Button } from '@antmjs/vantui';
import { toast, getCurrentPage } from '@vh-mobile/pro-utils';
import { CSpaceCustom } from '@vh-mobile/pro-components';
import MainContainerCustom from '@/components/MainContainerCustom';

export default function DemoToast() {
  return (
    <MainContainerCustom>
      <View className="index">
        <CSpaceCustom direction="vertical" align="center">
          <Button
            type="primary"
            block={true}
            onClick={() => {
              toast.loading();
              setTimeout(() => {
                toast.clear();
              }, 2000);
            }}
          >
            触发Loading自动关闭
          </Button>
          <Button
            type="primary"
            block={true}
            onClick={() => {
              toast.show('哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊');
            }}
          >
            普通提示
          </Button>
          <Button
            type="primary"
            block={true}
            onClick={() => {
              toast.success('成功啦');
            }}
          >
            成功提示
          </Button>
          <Button
            type="primary"
            block={true}
            onClick={() => {
              toast.fail('我失败啦');
            }}
          >
            失败提示
          </Button>
          <Button
            type="primary"
            block={true}
            onClick={() => {
              const page = getCurrentPage();
              toast.show(JSON.stringify(page));
            }}
          >
            获取页面信息
          </Button>
        </CSpaceCustom>
      </View>
    </MainContainerCustom>
  );
}
